<template>
	<view class="select-picker">
		<view class="select-mark" v-if="show" @click="closeModel"></view>
		<view class="content" :style="{ bottom: show ? 0 : `calc(-${height} - 200rpx)`}" >
			<view class="header" @click="closeModel" ><view class="line"></view></view>
			<view class="card_title">申请补卡</view>
			<view class="card_text">
				<view class=""><text>日期</text><text>{{dataObj.currYMD}}</text></view>
				<view class=""><text>补卡类型:</text><text>{{dataObj.typeCard === 1?'签到':'签退'}}</text></view>
				<view class="" style="display: flex;">
					<text>实际打卡:</text>
					<text v-if="dataObj.noCard" >缺卡</text>
					<text v-else style="color: #E02020;display: block;">{{(dataObj.typeCard == 1 ?dataObj.userSignDate:dataObj.userSignOutDate)||''}}{{ dataObj.typeCard === 1 ? (dataObj.lateTime? " 迟到"+dataObj.lateTime:'' ): (dataObj.LeaveTime?" 早退"+dataObj.LeaveTime:'')}}{{dataObj.typeCard==1?(dataObj.signType==2?',范围外打卡':''):(dataObj.signOutType==2?',范围外打卡':'')}}</text>
				</view>
				<view class=""><text>补卡理由:</text></view>
				<view class="t_reason">
					<textarea v-model="textTareaVal" @blur="bindTextAreaBlur" maxlength="300" placeholder="请输入补卡理由" placeholder-class="plcalss" />
					<text class="text_num" :style="{color:NumStr>=300?'#e02020;':'#666666;'}" >{{NumStr}}/300</text>
				</view>
			</view>	
			<view class="select-picker-bottom"><view class="select-picker-save" @click="handleSave">提交</view></view>
		</view>
		
	</view>
</template>

<script>
export default {
	props: {
		dataObj:{
			type:Object,
			default:()=>{
				return {};
			}
		},
		type: {
			type: Number,
			default: 1
		},
		title: {
			type: Array,
			default:()=>[]
		},
		show:{
			type:Boolean,
			default:false
		},
		height:{
			type:String,
			default:'750rpx'
		}
	},
	data() {
		return {
			textTareaVal:'',
			NumStr:0
		};
	},
	watch: {
	},
	computed: {},
	
	methods: {
		closeModel() {
			this.$emit('closeModel',false);
		},
		
		// 文本输入框
		bindTextAreaBlur(e) {
			this.NumStr = this.bindTexStr(e.detail.value,300);
		},
		bindTexStr(str,maxlength) {
			var result = '';
			if (str && str.length > maxlength) {
				result =  maxlength;
			} else {
				result = str.length;
			}
			return result;
		},
		handleSave() {
			if (!this.textTareaVal) {
				uni.showToast({
					title:'请输入补卡理由',
					icon:'none' 
				});
				return;
			}
			this.$emit('submitCard',this.textTareaVal);
			this.textTareaVal = '';
		}
	}
};
</script>
<style lang="scss" scoped>

.select-picker {
	// background: #ffffff;
	// border-radius: 8rpx 8rpx 0rpx 0rpx;
	// box-shadow: 0rpx -4rpx 12rpx 0rpx rgba(0, 0, 0, 0.12);
	.select-mark{
		width: 100%;
		height: 100vh;
		position: fixed;
		top:0;
		background-color: rgba(0, 0, 0, 0.4);
		z-index: 300;
	}
	
	.content {
		padding:40rpx;
		position: fixed;
		background-color: #fff;
		// width: 100%;
		bottom: 0;
		left:0;
		right: 0;
		z-index: 300;
		transition: 0.4s all;
		.header {
			background: #ffffff;
			// height: 67rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			// border-top: 2rpx solid #eeeeee;
			// border-bottom: 2rpx solid #eeeeee;
			.line {
				width: 64rpx;
				height: 10rpx;
				opacity: 1;
				background: #d8d8d8;
				border-radius: 6rpx;
			}
		}
		.card_title{
			margin-top: 20rpx;
			font-size: 32rpx;
			font-weight: 600;
			color: #333333;
		}
		.card_text{
			margin-top: 48rpx;
			view{
				margin: 24rpx 0;
				text:nth-child(1){
					display:inline-block;
					width: 150rpx;
					font-size: 28rpx;
					color: #666666;
				}
				text:nth-child(2){
					font-size: 28rpx;
					color: #333333;
				}
			}
			.t_reason{
				textarea{
					width: 100%;
					border: 2rpx #CCCCCC solid;
				}
				
				.text_num{
				  text-align: right;
				  font-size: 24rpx;
				  font-weight: 400;
				  color: #666666;
				  display: inherit;
				}
			}
			
		}
	}
	.select-picker-bottom {
		// padding: 30rpx 40rpx;
		.select-picker-save {
			display: flex;
			color: #fff;
			font-weight: 500;
			height: 70rpx;
			background: #0091ff;
			border-radius: 8rpx;
			align-items: center;
			justify-content: center;
		}
	}
	
}

</style>
